// careful not to get high! cuz my stuff is dope
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vi vector<int>
#define vc vector<char>
#define vll vector<ll>
#define vb vector<bool>
#define vp vector<pair<int,int>>
#define all(v) (v).begin()+1,(v).end()
#define pi pair<int,int>
#define mpi map<int,int>
#define edl '\n'
#define pyes cout<<"YES\n";
#define pno cout<<"NO\n";
#define pb(x) push_back(x)
#define fr(i,s,e) for(ll i = (ll)s; i < (ll)e; i++)
#define rfr(i,s,e) for(ll i = (ll)e; i >= (ll)s; i--)
#define fa(x,a) for(auto x: a)
#define read(a) for(auto &x: a) cin >> x;
#define put(a) for(auto &x: a) cout << x << " "; cout << nl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define files freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...)
#endif
#define int long long
template <typename C> void UNIQUE(vector<C> &v) { sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end()) - v.begin()); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
int n;cin>>n;
ll num=232792560;
vector<vp>contri(21,vp(200001,{0,0}));
fr(i,1,21) fr(j,1,200000)contri[i][j].second = j;
fr(i,0,n){
int m,k;cin>>m>>k;
fr(j,1,k+1)contri[j][m].first+=num;
fr(j,k + 1,21)contri[j][m].first+=(num/j)*k;
}
int ans=-1,ind=-1;
fr(i,1,21){
sort(all(contri[i]));
reverse(all(contri[i]));
ll curr=0;
fr(j,1,i+1)curr += contri[i][j].first;
if(curr>=ans){
ans = curr;
ind = i;
}
}
cout<<ind<<"\n";
fr(j,1,ind+1)cout<<contri[ind][j].second<<" ";
cout << "\n";
}
signed main(){
fast;
int tt=1;
while(tt--){
solve();
}
return 0;
}
1463B - Find The Array | 1538C - Number of Pairs |
621B - Wet Shark and Bishops | 476B - Dreamoon and WiFi |
152C - Pocket Book | 1681D - Required Length |
1725D - Deducing Sortability | 1501A - Alexey and Train |
721B - Passwords | 1263D - Secret Passwords |
1371B - Magical Calendar | 1726E - Almost Perfect |
1360C - Similar Pairs | 900A - Find Extra One |
1093D - Beautiful Graph | 748A - Santa Claus and a Place in a Class |
1511B - GCD Length | 676B - Pyramid of Glasses |
597A - Divisibility | 1632A - ABC |
1619D - New Year's Problem | 242B - Big Segment |
938A - Word Correction | 159C - String Manipulation 10 |
258A - Little Elephant and Bits | 1536C - Diluc and Kaeya |
1428C - ABBB | 1557A - Ezzat and Two Subsequences |
255A - Greg's Workout | 1059A - Cashier |